﻿using System;
using System.Collections.Generic;
using Bingosoft.Core;
using Bingosoft.Core.Ioc;
using Bingosoft.Modules.SecurityConsole.Common.Helper;
using Bingosoft.Modules.SecurityConsole.User;

namespace Bingosoft.Modules.SecurityConsole.Common.FunctionControl.ListSelect
{
    class UserAddRoleListSelectService : IListSelectService
    {
        public bool Save(string oldIds, string oldNames, string newIds, string newNames, IDictionary<string, object> parameters)
        {
		    String[] newIdsString = newIds.Split(',');
            string userId = DictionaryHelper.GetParamString(parameters,"USER_ID");
            return GetUserService().AddRolesForUser(userId, newIdsString);
        }

        private static UserService GetUserService()
        {
            IObjectContainer container = App.ObjectContainer;
            UserService service = container.GetObject<UserService>("UserService");
            return service;
        }
    }
}
